package com.sihai.ehr.service;

import com.sihai.core.Limit;
import com.sihai.core.LimitedList;
import com.sihai.core.Sorter;
import com.sihai.ehr.model.biz.*;
import com.sihai.ehr.model.sys.AuditStatus;
import com.sihai.ehr.model.sys.ExaminePeriodEnum;
import com.sihai.ehr.model.sys.User;
import com.sihai.ehr.web.pojo.ExamDataInputPojo;

import java.util.List;


public interface ExamQuanDataInputService {

    /**
     * 获取定量考核打分对象集合
     *
     * @param organizationId
     *            组织架构ID
     * @param dutyId
     *            职务ID
     * @param periodType
     *            考核周期类型
     * @param period
     *            考核期数
     * @param status
     *            打分状态{0:未打分,1:已打分}
     * @param limit
     * @param sorter
     * @return
     */
    LimitedList<ExamDataInputPojo> searchExamQuanScores(Long organizationId,
                                                        Long dutyId, ExaminePeriodEnum periodType, Long period, int status,
                                                        Limit limit, Sorter sorter);


    /**
     * 根据职务获取打分项目列表
     * @param dutyId
     *          职务ID
     * @return
     */
    LimitedList<ExamQuanItemSet> findExamQuanItemSetByDuty(Long dutyId,Limit limit,Sorter sorter);


    /**
     * create wxn
     * 查询定量数据输入界面中的未输入数据列表
     */
    LimitedList<EmployeeinfoWork> searchExamQuanUnInputs(Long organizationId, ExamEmbedPeriod examPeriod, Limit limit, Sorter sorter);
    /**
     * create wxn
     * 查询定量数据输入界面中的未输入数据列表(按item列表，员工存在重复)
     */
    LimitedList<EmployeeinfoWork> searchExamQuanUnInputsByItems(User currentUser, Long organizationId, ExamEmbedPeriod examPeriod, Limit limit, Sorter sorter);

    /**
     * create wxn
     * 根据职务和周期类型得到定量输入列表
     */
    List<ExamQuanItemSet> findExamQuanItemSetForInput(User currentUser, Long dutyId, ExaminePeriodEnum periodEnum, Limit limit, Sorter sorter);

    ExamQuanItemSet getExamQuanItemSet(Long id);

    ExamQuanScoreDetail getExamQuanScoreDetail(Long id);

    //添加或更新数据输入
    void saveDateInputs(List<ExamQuanScoreDetail> scoreDetails);

    //按周期类型统计考核项目数
    Long totalQuanItems(ExaminePeriodEnum periodEnum, Long organizationId);

    //按状态+周期类型+周期+部门统计已输入的考核项目数
    Long totalQuanDetails(ExamEmbedPeriod embedPeriod, AuditStatus status, Long organizationId);

    //按指定状态,workId, 周期,部门查找量化数据输入项(type:按输入人找或还是按审核人找)
    LimitedList<ExamQuanScoreDetail> searchExamQuanDetails(String type, User currentUser, Long organizationId, Long workId, ExamEmbedPeriod embedPeriod, AuditStatus status, Limit limit, Sorter sorter);

    //审核
    void saveQuanAuditing(ExamQuanScoreAuditing audit);

    //查找指定定量数据的历史审核记录
    List<ExamQuanScoreAuditing> findExamQuanScoreAudits(Long quanScoreDetailId);

    //查找历史记录
    LimitedList<ExamQuanScoreDetail> findExamQuanScoreDetails(Long workId, String year, Long itemId, Limit limit, Sorter sorter);

    //按大周期和员工ID查找定量打分详细
    List<ExamQuanScoreDetail> findExamQuanScoreDetails(Long workId, Long periodId);

    //检查是否可提交输入
    boolean submitCheck(ExamEmbedPeriod period, User loginUser);

    //提交输入
    boolean submitInput(ExamEmbedPeriod period, User loginUser);

    //得到上一期考核分数
    Float prevScore(Long workId, ExaminePeriodEnum examPeriodEnum);
}
